//
//  TableViewContorollerSectionedByAlphabets.h
//  MantuPlay
//
//  Created by Markus Sintonen on 14.8.2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DatabaseObjectDataSource.h"
#import "GenericDatabaseObject.h"

@interface TableViewContorollerSectionedByAlphabets : UIViewController<UITableViewDelegate, UITableViewDataSource> {
	UITableView *theTableView;
	
	NSDictionary *objectsByInitialLetter;
	NSArray *initialLetters;
	
	id<DatabaseObjectDataSource> dataSource;
}

@property (nonatomic,retain) UITableView *theTableView;
@property (nonatomic,retain) id<DatabaseObjectDataSource> dataSource;

-(id)initWithDataSource:(id<DatabaseObjectDataSource>)theDataSource;
@end

//Private methods
@interface TableViewContorollerSectionedByAlphabets ()
-(id)objectAtIndexPath:(NSIndexPath*)indexPath;

-(NSDictionary*)dictionaryOfObjectsByInitialLetter;
-(NSString*)keyFromInitialLetter:(NSString*)letter;
-(void)addObject:(id)obj toAlphabetDictionary:(NSMutableDictionary*)dict;

-(unsigned int)numberOfItems;
-(BOOL)showTableSectioned;
@end
